package lab03.test13;

import java.sql.*;

public class Test {
    public static void main(String[] args) {
        Connection connection=null;
        Statement statement=null;
        ResultSet resultSet=null;

        String sql="insert into " +
                "t_students(real_name,age,gender,department,stu_no) "+
        "values('大东',20,1,'信息学院','1266')";

        try {
            Class.forName("com.mysql.cj.jdbc.Driver");

            connection= DriverManager.getConnection
                    (
                    "jdbc:mysql://localhost:3306/java-2017?serverTimezone=UTC",
                    "root",
                    "13551108259"
                   );

            statement=connection.createStatement();
            statement.execute(sql);
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } catch (SQLException e) {
            e.printStackTrace();
        }finally {
            try {
                statement.close();
                connection.close();
                resultSet.close();
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }
    }

}
